home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LT_ShowWindow.c < prev    next >
C/C++ Source or Header  |  1996-08-22  |  2KB  |  123 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /****** gtlayout.library/LT_ShowWindow ******************************************
  15. *
  16. *   NAME
  17. *    LT_ShowWindow -- Make a window visible
  18. *
  19. *   SYNOPSIS
  20. *    LT_ShowWindow(Handle,Activate);
  21. *                    A0      A1
  22. *
  23. *    VOID LT_ShowWindow(LayoutHandle *,BOOL);
  24. *
  25. *   FUNCTION
  26. *    The window attached to a LayoutHandle is made visible, this
  27. *    involves bringing it to the front, bringing the screen to
  28. *    the front the window resides on, unzooming the window and
  29. *    also moving the visible part of an autoscrolling screen.
  30. *
  31. *   INPUTS
  32. *    Window - Pointer to Window structure.
  33. *
  34. *    Activate - If TRUE the window will be activated as soon
  35. *        as it has been brought to the front.
  36. *
  37. *   RESULT
  38. *    none
  39. *
  40. *   NOTES
  41. *    The arguments are passed in A0 and A1, this is *not* a
  42. *    typo.
  43. *
  44. *   BUGS
  45. *    In revisions earlier than v21 this routine consistently
  46. *    failed to reliably unzip a window in zoomed state. This
  47. *    could cause the calling application to wait for about
  48. *    five seconds before continuing execution.
  49. *
  50. *   SEE ALSO
  51. *    intuition.library/MoveScreen
  52. *    intuition.library/ScreenPosition
  53. *    intuition.library/ZipWindow
  54. *
  55. ******************************************************************************
  56. *
  57. */
  58.  
  59. VOID LIBENT
  60. LT_ShowWindow(REG(a0) LayoutHandle *handle,REG(a1) BOOL activate)
  61. {
  62.     if(handle)
  63.     {
  64.         struct Window *window;
  65.         ULONG flags,mask;
  66.  
  67.         window = handle->Window;
  68.         flags = NULL;
  69.         mask = NULL;
  70.  
  71.         WindowToFront(window);
  72.  
  73.         if(activate)
  74.         {
  75.                 // activate the window
  76.  
  77.             ActivateWindow(window);
  78.  
  79.                 // wait for the window to become active
  80.  
  81.             flags |= WFLG_WINDOWACTIVE;
  82.             mask |= WFLG_WINDOWACTIVE;
  83.         }
  84.  
  85.         ScreenToFront(window->WScreen);
  86.  
  87.         if(!handle->ResizeView && (handle->Window->Flags & (WFLG_HASZOOM | WFLG_ZOOMED)) == (WFLG_HASZOOM | WFLG_ZOOMED))
  88.         {
  89.                 // make the window full-sized
  90.  
  91.             ZipWindow(window);
  92.  
  93.                 // wait for the zoom bit to get cleared
  94.  
  95.             flags &= ~WFLG_ZOOMED;
  96.             mask |= WFLG_ZOOMED;
  97.         }
  98.  
  99.             // wait for the window to change state?
  100.  
  101.         if(mask)
  102.         {
  103.             LONG i;
  104.  
  105.                 // wait for the window to change state
  106.  
  107.             for(i = 0 ; i < 300 ; i++)
  108.             {
  109.                 if((handle->Window->Flags & mask) == flags)
  110.                     break;
  111.                 else
  112.                     WaitTOF();
  113.             }
  114.         }
  115.  
  116.             // make the window visible on the screen by
  117.             // scrolling it into view
  118.  
  119.         if(handle->MoveToWindow)
  120.             LTP_MoveToWindow(handle);
  121.     }
  122. }
  123.